package com.lx.demo;

import java.time.LocalDate;
import java.util.Scanner;

/**
 * @author c先生
 * @date 2022年03月29日 下午 8:32:47
 * @describe
 */

public class MainUI {
    public static void main(String[] args) {
        EmpManager em = new EmpManager();
        while (true) {
            System.out.println("----------管理---------");
            System.out.println("1.查看本公司所有的员工信息");
            System.out.println("2.根据部门名称查看当前部门门的所有员工信息");
            System.out.println("3.新增一个部门");
            System.out.println("4.新增一个员工");
            System.out.println("5.转岗");
            System.out.println("6.输入一个年份，给满足此年份员工涨2000工资");
            System.out.println("7.删除一名员工");//张三公司就一个直接删  存在多个展示让用户挑选删
            Scanner sc = new Scanner(System.in);
            int key = sc.nextInt();
            switch (key) {
                case 1:
                    em.showAll();
                    break;
                case 2:
                    System.out.println("目前有以下部门：");
                    System.out.print(em.getAllDeptName()+"  ");
                    System.out.println();
                    System.out.println("请输入部门名称：");
                    em.showEmpByDept(sc.next());
                    break;
                case 3:
                    System.out.println("请输入部门编号：");
                    int deptNum = sc.nextInt();
                    System.out.println("请输入部门名称：");
                    String deptName = sc.next();
                    System.out.println("请输入部门描述：");
                    String deptDescribe = sc.next();
                    System.out.println("请输入门牌号：");
                    int officeNum = sc.nextInt();
                    System.out.println("请输入位置：");
                    String officeLocal = sc.next();
                    Office office = new Office(officeNum, officeLocal);
                    boolean flag = em.addDept(deptNum, deptName, deptDescribe, office);
                    if (flag) {
                        System.out.println("新增成功！");
                    } else {
                        System.out.println("新增失败！");
                    }
                    break;
                case 4:
                    System.out.println("请输入员工所属部门名称：");
                    String deptName1 = sc.next();
                    System.out.println("请输入员工编号：");
                    int empNum = sc.nextInt();
                    System.out.println("请输入员工姓名：");
                    String empName = sc.next();
                    System.out.println("请输入员工性别：");
                    String empGender = sc.next();
                    System.out.println("请输入员工入职时间(年 月 日)：");
                    LocalDate empHirDate = LocalDate.of(sc.nextInt(),sc.nextInt(),sc.nextInt());
                    System.out.println("请输入员工薪资：");
                    Double empSalary = sc.nextDouble();
                    System.out.println("请输入员工籍贯：");
                    String homeTown = sc.next();
                    System.out.println("请输入员工等级：");
                    String empLevel = sc.next();
                    em.addEmp(deptName1,empNum,empName,empGender,empHirDate,empSalary,homeTown,empLevel);
                    break;
                case 5:
                    System.out.println("请输入员工原部门名称：");
                    String oldDeptName = sc.next();
                    System.out.println("请输入转岗员工编号：");
                    Integer empNum1 = sc.nextInt();
                    System.out.println("请输入要去的部门名称：");
                    String newDeptName = sc.next();
                    boolean flag1 = em.EmpChangeStation(oldDeptName,empNum1,newDeptName);
                    if(flag1){
                        System.out.println("转岗成功！");
                    }else {
                        System.out.println("转岗失败！");
                    }
                    break;
                case 6:
                    System.out.println("请输入年份：");
                    if(em.increaseSalary(sc.nextInt())){
                        System.out.println("涨薪成功！");
                    }else {
                        System.out.println("涨薪失败！");
                    };
                    break;
                case 7:
                    System.out.println("请输入员工姓名：");
                    String empName4 = sc.next();
                    int count = em.countEmp(empName4);
                    if(count==1){
                        if(em.deleteEmp(empName4)){
                            System.out.println("删除成功！");
                        }else {
                            System.out.println("删除失败！");
                        };
                    }else if(count>1){
                        System.out.println("同名员工如下：");
                        em.showEmp(empName4);
                        System.out.println("请输入编号：");
                        if(em.deleteEmp2(sc.nextInt())){
                            System.out.println("删除成功！");
                        }else {
                            System.out.println("删除失败！");
                        };
                    }else {
                        System.out.println("该员工不存在！");
                    }
                    break;
            }
        }
    }
}
